package com.itcam.iostream_;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Author:Cammy.Wu
 * Date:2024-05-13
 * Description:利用DataOutputStream向外写出变量
 */

public class DataSteramDemo01 {
    public static void main(String[] args) throws IOException {
        // DataOutputStream将内存中的基本数据类型和字符串的变量写入文件中
//        File f = new File("E:\\IOStream\\DataStream01.txt");
//        FileOutputStream fos = new FileOutputStream(f);
//        DataOutputStream dos = new DataOutputStream(fos);
        DataOutputStream dos=new DataOutputStream(new FileOutputStream(new File("E:\\IOStream\\DataStream01.txt")));

        // 向外将变量写到文件中
        dos.writeUTF("簸箕");
        dos.writeBoolean(false);
        dos.writeDouble(7.9);
        dos.writeInt(82);

        // 关闭流
        dos.close();

    }
}
